Micron Document
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| SparkN0de-git | SparkN0de |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Commit 8d9f4956dba456763838d00282e9e0674f9f1492


Parents : 062e319
Author : Mark Qvist <mark@unsigned.io>
Date : 2023-09-19T11:56:04+02:00

Improved request failure handling

Changes

1 files changed, 16 insertions(+), 1 deletions(-)


Diff

diff --git a/nomadnet/ui/textui/Browser.py b/nomadnet/ui/textui/Browser.py
index 4cd6ce0..d5f3763 100644
--- a/nomadnet/ui/textui/Browser.py
+++ b/nomadnet/ui/textui/Browser.py
@@ -756,7 +756,7 @@ class Browser:
def __load(self):
# If an established link exists, but it doesn't match the target
# destination, we close and clear it.
- if self.link != None and self.link.destination.hash != self.destination_hash:
+ if self.link != None and (self.link.destination.hash != self.destination_hash or self.link.status != RNS.Link.ACTIVE):
self.link.teardown()
self.link = None
@@ -1005,6 +1005,11 @@ class Browser:
self.response_transfer_size = None
self.update_display()
+ if self.link != None:
+ try:
+ self.link.teardown()
+ except Exception as e:
+ pass
else:
self.status = Browser.REQUEST_FAILED
self.response_progress = 0
@@ -1012,6 +1017,11 @@ class Browser:
self.response_transfer_size = None
self.update_display()
+ if self.link != None:
+ try:
+ self.link.teardown()
+ except Exception as e:
+ pass
def request_timeout(self, request_receipt=None):
@@ -1021,6 +1031,11 @@ class Browser:
self.response_transfer_size = None
self.update_display()
+ if self.link != None:
+ try:
+ self.link.teardown()
+ except Exception as e:
+ pass
def response_progressed(self, request_receipt):


──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────